<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<title>Mont Blanc Foot F7 - Dar de Alta Jugadores</title>

		<?php $this -> load -> view('head_view');?>
		
		<script language="javascript" type="text/javascript">
			$( function() {
				
				var match_id = <?php echo $match_ide;?>;
				
				$("#score-div").load("/index.php/matches/scorematchajax/"+match_id);
			
				$('input:submit').button();
				
				$('#match_time').datetimepicker({
					ampm: true
				});
				
				$('#add-score-visit').click( function() {

					$.post("/index.php/matches/savescore", {
						'match_id' : $('#match_id').val(),
						'player_id' : $('#team_player_visit').val(),
						'team_id': $('#team_visit_id').val(),
						'time' : $('#time_score_visit').val()
					}, function(response) {
						//$("#dbdisplay").html(response);
						var $dialog = $('<div></div>')
						.html('Anotaci&oacute;n Guardada!')
						.dialog({
							autoOpen: false,
							title: 'Guardar anotaci&oacute;n',
							buttons: {
								"Ok": function() {

									$(this).dialog("close");
									//$('#loading-gif').hide();
								}
							}

						});
						$("#score-div").load("/index.php/matches/scorematchajax/"+match_id);
						//$("#team-players-div").load("/index.php/teams/playerListingAJAX/"+team_id);
						//$("#non-players-div").load("/index.php/teams/nonPlayerListingAJAX/"+team_id);
						$dialog.dialog('open');
						//alert("Jugadores Agregados!")
					});
					return false;
				});
				
				$('#change_date_match').click( function(){
				
					$.post("/index.php/matches/modifydate", {
						'match_id' : $('#match_id').val(),
						'match_time' : $('#match_time').val()
					}, function(response) {
						//$("#dbdisplay").html(response);
						var $dialog = $('<div></div>')
						.html('La hora del encuentro ha sido cambiada!')
						.dialog({
							autoOpen: false,
							title: 'Modificar encuentro',
							buttons: {
								"Ok": function() {

									$(this).dialog("close");
									//$('#loading-gif').hide();
								}
							}

						});
						$dialog.dialog('open');
					});
					
					
				
				});
				
				$('#add-score-home').click( function() {

					$.post("/index.php/matches/savescore", {
						'match_id' : $('#match_id').val(),
						'player_id' : $('#team_player_home').val(),
						'team_id': $('#team_home_id').val(),
						'time' : $('#time_score_home').val()
					}, function(response) {
						//$("#dbdisplay").html(response);
						var $dialog = $('<div></div>')
						.html('Anotaci&oacute;n Guardada!')
						.dialog({
							autoOpen: false,
							title: 'Guardar anotaci&oacute;n',
							buttons: {
								"Ok": function() {

									$(this).dialog("close");
									//$('#loading-gif').hide();
								}
							}

						});
						$("#score-div").load("/index.php/matches/scorematchajax/"+match_id);
						//$("#team-players-div").load("/index.php/teams/playerListingAJAX/"+team_id);
						//$("#non-players-div").load("/index.php/teams/nonPlayerListingAJAX/"+team_id);
						$dialog.dialog('open');
						//alert("Jugadores Agregados!")
					});
					return false;
				});
			});
		</script>
	</head>
	<body id="page1">
		<div id="line-hor-score-home">
		</div>
		<div id="line-hor-score-visit">
		</div>
		<div id="line-hor-score-final">
		</div>

		<div id="main-bg-top">
			<div id="main-bg-bot">
				<div id="main">
					<!-- header -->
					<div id="header">
						<?php $this -> load -> view('league_header');?>
					</div>
					<!-- content -->
					<div id="content">
						<!-- script -->
						<div id="indent">
							<!-- scroller news
							<div id="flexform">

							</div>-->
							<h2>
							<?php echo $team_home_name . " VS " . $team_visit_name;?>
							</h2>
							<h3>
							<?php echo $match_date;?>
							</h3>
							<!--
							<p>
							<a id="add-score" class="ui-avena-button ui-state-default ui-corner-all" href="#">
							<span class="ui-icon ui-icon-contact"></span>
							Ver Ficha
							</a>
							</p>
							-->

							<!--

							Form for home team.

							-->

							<?php echo form_open('matches/save', 'id="score-setter-home"');?>
							<h1>
							Equipo Local - <?php echo $team_home_name;?>
							</h1>
							<br />
							<p>
								<label for="team_home">
									Jugadores(Local):
								</label>
								<br/>
								<?php echo form_dropdown('team_player_home', $players_home, '', 'id="team_player_home"');?>
							</p>
							<p>
								<label for="time_score">
									Tiempo de la anotacion (Minuto):
								</label>
								<br />
								<input id="time_score_home" type="text" name="time_score">
								<?php echo form_input($match_id);?>
								<?php echo form_input($team_home_id);?>
							</p>
							<p>
								<a id="add-score-home" class="ui-avena-button ui-state-default ui-corner-all" href="#">
								<span class="ui-icon ui-icon-contact"></span>
								Guardar anotaci&oacute;n.
								</a>
							</p>
							<?php echo form_close();?>

							<!--

							Form for visit team.

							-->
							<br />
							<?php echo form_open('matches/save', 'id="score-setter-visit"');?>
							<h1>
							Equipo Visitante - <?php echo $team_visit_name;?>
							</h1>
							<br />
							<p>
								<label for="team_home">
									Jugadores(Local):
								</label>
								<br/>
								<?php echo form_dropdown('team_player_visit', $players_visit, '', 'id="team_player_visit"');?>
							</p>
							<p>
								<label for="time_score">
									Tiempo de la anotacion (Minuto):
								</label>
								<br />
								<input id="time_score_visit" type="text" name="time_score">
								<?php echo form_input($match_id);?>
								<?php echo form_input($team_visit_id);?>
							</p>

							<p>
								<a id="add-score-visit" class="ui-avena-button ui-state-default ui-corner-all" href="#">
								<span class="ui-icon ui-icon-contact"></span>
								Guardar anotaci&oacute;n.
								</a>
							</p>
							<?php echo form_close();?>
							</br>
						</br>
							<h1>
							Editar hora del encuentro - <?php echo $team_visit_name;?> vs <?php echo $team_home_name;?>
							</h1>
							<br />
							<p>
								<label for="match_time">
									Hora del Juego
								</label>
								<br />
								<input id="match_time" type="text" name="match_time" value="<?php echo $match_date_format ?>">
							</p>
							<p>
								<a id="change_date_match" class="ui-avena-button ui-state-default ui-corner-all" href="#">
									<span class="ui-icon ui-icon-contact"></span>
									Cambiar la hora del encuentro.
								</a>
							</p>
							<!--
							<p>
							<a id="add-score" class="ui-avena-button ui-state-default ui-corner-all" href="#">
							<span class="ui-icon ui-icon-contact"></span>
							Ver Ficha
							</a>
							</p>
							-->
							<?php //echo form_open('matches/save');?>
							<?php //echo form_submit('submit', 'Guardar');?><?php //echo form_close();?>

							<div id="score-div">
								
								<!-- 
								<h2>Marcador Final</h2>
								<table class='score-header'>
									<t>
										<th>Match</th>
										<th>vs</th>
										<th>Test</th>
										</tr>
										<tr>
											<td>0</td>
											<td>-</td>
											<td>2</td>
										</tr>
								</table>

								<table class='score-annotation'>
									<tr>
										<th colspan="2">
										<h1>Anotaciones</h1>
										</th>
									</tr>
									<tr>
										<td class='home'>
										<a href="#">Fuckencio Perez</a> (54')
										</td>
										<td class='visit'>
										<a href="#">Perenganito Mendez</a> (54')
										</td>
									</tr>
								</table>
								<br />
								-->
							</div>

							<?php echo form_close();?>
							<!--
							<p>
							<a id="add-score" class="ui-avena-button ui-state-default ui-corner-all" href="#">
							<span class="ui-icon ui-icon-contact"></span>
							Ver Ficha
							</a>
							</p>
							-->
							<?php echo form_open('matches/save');?>
							<?php echo form_input($match_id);?>
							<?php echo form_submit('submit', 'Guardar Marcador Final');?><?php echo form_close();?>
						</div>
					</div>
					<!-- footer -->
					<div id="footer">
						<?php $this -> load -> view('league_footer');?>
					</div>
				</div>
			</div>
		</div>
	</body>
</html>
